﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace BZOrderPrint
{
    public static class PrintHelper
    {
        [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern long SetDefaultPrinter(string pszPrinter);

        private const string _faceSheetPrinterKey = "FaceSheetPrinter";

        private const string _paperPrinterKey = "PaperPrinter";

        public static bool Verification()
        {
            var faceSheetPrinterValue = ConfigHelper.GetAppSettingValue(_faceSheetPrinterKey);
            var paperPrinterValue = ConfigHelper.GetAppSettingValue(_paperPrinterKey);
            if (string.IsNullOrEmpty(faceSheetPrinterValue) || string.IsNullOrEmpty(paperPrinterValue))
                return false;
            return true;
        }

        public static void FaceSheetPrinter()
        {
            var faceSheetPrinterValue = ConfigHelper.GetAppSettingValue(_faceSheetPrinterKey);
            SetDefaultPrinter(faceSheetPrinterValue);
        }

        public static void PaperPrinter()
        {
            var paperPrinterValue = ConfigHelper.GetAppSettingValue(_paperPrinterKey);
            SetDefaultPrinter(paperPrinterValue);
        }
    }
}
